﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace MetaDemo.Tabs
{
    public partial class AssemblyMetrics : UserControl
    {

        public static TabPage Get(Assembly a)
        {
            // Display information on the object.
            var metrics = new AssemblyMetrics();

            InitializeAssemblyMetrics(metrics, a);

            // Create a tab page in which to display the information above.
            var page = GetTabPage();
            page.Controls.Add(metrics);

            return page;
        }

        private static void InitializeAssemblyMetrics(AssemblyMetrics control, Assembly a)
        {
            // Assembly Metrics
            var assemblyAnalzer = new Metrics.AssemblyAnalyzer(a);
            control.lblMaxInheritanceDepthValue.Text = assemblyAnalzer.MaxInheritanceDepth
                + " (" + assemblyAnalzer.MaxInheritanceDepthType.FullName + ")";
            control.lblAvgNoOfMethods.Text = assemblyAnalzer.AvgMethodCountPerClass.ToString();
        }

        private static TabPage GetTabPage()
        {
            var page = new TabPage();

            page.Location = new System.Drawing.Point(4, 22);
            page.Name = "tabAssemblyMetrics";
            page.Padding = new System.Windows.Forms.Padding(3);
            page.Size = new System.Drawing.Size(428, 391);
            page.Text = "Assembly Metrics";
            page.TabIndex = 2;
            page.UseVisualStyleBackColor = true;

            return page;
        }
        
        public AssemblyMetrics()
        {
            InitializeComponent();
        }

    }
}
